﻿using MediatR;
using Traceability.Commont.Domains.ScratchTheFat;
using Traceability.Commont.DTOs.CommontFiles;
using Traceability.Commont.Infrastructures.Interfaces;

namespace U.Enterprise.Api.Applications.LoginNEwSheet
{
    public class ApproachInspectionCreateHandler : IRequestHandler<ApproachInspectionCreateCommond, Resqults>
    {

        private readonly IBateRepository<ApproachInspectionSheet> _ApproachInspectionSheet;

        public ApproachInspectionCreateHandler(IBateRepository<ApproachInspectionSheet> approachInspectionSheet)
        {
            _ApproachInspectionSheet = approachInspectionSheet;
        }

        public async Task<Resqults> Handle(ApproachInspectionCreateCommond request, CancellationToken cancellationToken)
        {
            try
            {


                var list=new Resqults() { Code=0};

                var query = new ApproachInspectionSheet()
                {
                    Approachid = request.Approachid,
                    ShoppgingDesignation = request.ShoppgingDesignation,
                    PutStorageStash = request.PutStorageStash,
                    PutStorageType = request.PutStorageType,
                    ProClassTissue = request.ProClassTissue,
                    ProductionlotNumber = request.ProductionlotNumber,
                    ProDuctionTime = request.ProDuctionTime,
                    putDesNum = request.putDesNum,
                    PutNum = request.PutNum,
                    receiptTime = request.receiptTime
                };


                var result= await _ApproachInspectionSheet.Add(query);
                if(result !=null)
                {
                    list.Code = 1;
                }

                return list;


            }
            catch (Exception)
            {

                throw;
            }
        }
    }
}
